package com.funmi.lizip.security.handler;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.funmi.lizip.common.base.R;
import com.funmi.lizip.common.base.ResultCode;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ClimbAccessDeineHandler implements AccessDeniedHandler {
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response,
                       AccessDeniedException accessDeniedException) throws IOException, ServletException {
        // 返回错误消息
       /* ObjectMapper objectMapper = new ObjectMapper();
        R result = R.fail().code(ResultCode.LOGIN_AUTH).message("没有访问权限!");

        // 403 表示要求客户端认证
        response.setStatus(HttpStatus.FORBIDDEN.value());
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(objectMapper.writeValueAsString(result));*/
    }
}